package sk.stuba.fiit.clientApp.util;

import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;


import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class Util {
	private static Random generator = new Random();
	private static BASE64Decoder decoder = new BASE64Decoder();
	private static BASE64Encoder encoder = new BASE64Encoder();

	
	public static  byte[] generateByte(int lenght){
		byte [] randomByte  = new byte[lenght];
		generator.nextBytes(randomByte);   
		return randomByte; 
	}
	
	public static byte[] decodeBase64StringToByte(String data) throws IOException{
		return decoder.decodeBuffer(data);
	}
	
	public static String codeByteToBase64String(byte data[]){
		return encoder.encode(data);
	}
	
	public static final String ENCODING_BASE64 = "base64Binary";
	public static final String ENCODING_BASE64_URI = "http://www.w3.org/2000/09/xmldsig#base64";
	public static final String XMLDSIG_PREFIX= "http://www.w3.org/2000/09/xmldsig#";
	public static final String SIGNED_PROPERTIES_TYPE = "http://uri.etsi.org/01903#SignedProperties";
	public static final String CANONICALIZATION_OMITS_COMMENTS1_0 = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
	public static final String CANONICALIZATION_WITH_COMMENTS = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
	public static final String CANONICALIZATION_OMITS_COMMENTS1_1 = "http://www.w3.org/2006/12/xml-c14n11";
	public static final String CANONICALIZATION_WITH_COMMENTS1_1 = "http://www.w3.org/2006/12/xml-c14n11#WithComments";
	public static final String TRANSFORM_DETACHED = "http://www.w3.org/2000/09/xmldsig#detached-signature";
}
